package com.xujie.sportsmeeting.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

/**
 * 团体统计VO
 */
@Data
@Schema(description = "团体统计信息")
public class TeamStatisticsVO {

    @Schema(description = "统计类型")
    private Integer statisticsType;

    @Schema(description = "统计类型描述")
    private String statisticsTypeText;

    @Schema(description = "团体名称")
    private String teamName;

    @Schema(description = "院系名称")
    private String department;

    @Schema(description = "班级名称")
    private String className;

    @Schema(description = "总得分")
    private BigDecimal totalScore;

    @Schema(description = "男子得分")
    private BigDecimal maleScore;

    @Schema(description = "女子得分")
    private BigDecimal femaleScore;

    @Schema(description = "参赛人数")
    private Integer participantCount;

    @Schema(description = "男子参赛人数")
    private Integer maleParticipantCount;

    @Schema(description = "女子参赛人数")
    private Integer femaleParticipantCount;

    @Schema(description = "金牌数")
    private Integer goldMedalCount;

    @Schema(description = "银牌数")
    private Integer silverMedalCount;

    @Schema(description = "铜牌数")
    private Integer bronzeMedalCount;

    @Schema(description = "总奖牌数")
    private Integer totalMedalCount;

    @Schema(description = "总排名")
    private Integer totalRanking;

    @Schema(description = "男子排名")
    private Integer maleRanking;

    @Schema(description = "女子排名")
    private Integer femaleRanking;

    @Schema(description = "人均得分")
    private BigDecimal averageScore;

    @Schema(description = "参与项目数")
    private Integer participatedEvents;

    @Schema(description = "获奖率")
    private BigDecimal medalRate;

    @Schema(description = "破纪录次数")
    private Integer recordBreakingCount;

    @Schema(description = "优势项目")
    private List<String> advantageEvents;

    @Schema(description = "参赛项目分布")
    private List<EventParticipationVO> eventDistribution;

    // 获取统计类型描述
    public String getStatisticsTypeText() {
        if (statisticsType == null) return "";
        return statisticsType == 1 ? "院系统计" : "班级统计";
    }

    // 获取总奖牌数
    public Integer getTotalMedalCount() {
        int total = 0;
        if (goldMedalCount != null) total += goldMedalCount;
        if (silverMedalCount != null) total += silverMedalCount;
        if (bronzeMedalCount != null) total += bronzeMedalCount;
        return total;
    }

    // 获取排名展示文本
    public String getRankingText() {
        if (totalRanking == null || totalRanking <= 0) return "";
        
        switch (totalRanking) {
            case 1: return "🥇 第一名";
            case 2: return "🥈 第二名";
            case 3: return "🥉 第三名";
            default: return "第" + totalRanking + "名";
        }
    }
}
